//
//  STComposeController.m
//  OCVVeibo
//
//  Created by leergou on 16/9/3.
//  Copyright © 2016年 WhiteHouse. All rights reserved.
//

#import "STComposeController.h"

@interface STComposeController ()

@property (nonatomic,strong) UILabel *titleView;

@end

@implementation STComposeController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = RANDOMCOLOR;
    
    [self setupNav];
    [self setupUI];
    
}

#pragma mark - 按钮点击 -

- (void)cancelAction{
    NSLog(@"取消发布");
}
- (void)publishAction{
    
    NSLog(@"直接发布");
}

#pragma mark - setupUI -
- (void)setupUI{
    
}
#pragma mark - setupNav -
- (void)setupNav{
    // 导航栏中间文字
    self.navigationItem.titleView = self.titleView;
    
    // leftItem
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" target:self action:@selector(cancelAction)];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"发布" target:self action:@selector(publishAction)];
    
    self.navigationItem.rightBarButtonItem.enabled = NO;
}


#pragma mark - lazy -
- (UILabel *)titleView{
    
    if (!_titleView) {
        
        // 创建 UILabel 对象
        _titleView = [[UILabel alloc] init];
        
        // 拼接标题
        NSString *screenName =  [STUserAccountVM sharedUserAccountTools].userAccountDTO.screen_name;
        
        NSString *title = [NSString stringWithFormat:@"发微博\n%@",screenName];
        
        // 创建一个富文本
        NSMutableAttributedString *mutableString = [[NSMutableAttributedString alloc] initWithString:title];
        
        NSRange range = [title rangeOfString:screenName];
        
        [mutableString addAttributes:@{NSForegroundColorAttributeName:ThemeColor,NSFontAttributeName:[UIFont systemFontOfSize:12]} range:range];
        
        // 设置文本属性
        _titleView.textAlignment = NSTextAlignmentCenter;
        _titleView.numberOfLines = 0;
        _titleView.attributedText = mutableString;
        [_titleView sizeToFit];
    }
    return _titleView;
}


@end
